From c177a9f12257b753181974fca1da88f9bbc28e80 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 6 May 2010 11:13:22 +0100 Subject: [PATCH] xm: Add exception handling when launching vncviewer Also replaces the call to 'puts' with 'print' as the former is undefined in python Signed-off-by: Goncalo Gomes --- tools/python/xen/xm/console.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xm/console.py b/tools/python/xen/xm/console.py index f31d561836..ce86369c63 100644 --- a/tools/python/xen/xm/console.py +++ b/tools/python/xen/xm/console.py @@ -74,10 +74,15 @@ def runVncViewer(domid, do_autopass, do_daemonize=False): if do_daemonize: pid = utils.daemonize('vncviewer', cmdl, vnc_password_tmpfile) if pid == 0: - puts >>sys.stderr, 'failed to invoke vncviewer' + print >>sys.stderr, 'failed to invoke vncviewer' os._exit(-1) else: print 'invoking ', ' '.join(cmdl) if vnc_password_tmpfile is not None: os.dup2(vnc_password_tmpfile.fileno(), 0) - os.execvp('vncviewer', cmdl) + try: + os.execvp('vncviewer', cmdl) + except OSError: + print >>sys.stderr, 'Error: external vncviewer missing or not \ +in the path\nExiting' + os._exit(-1) -- 2.30.2